﻿namespace Model
{
    #region usings

    using System;

    using Common;

    #endregion

    public class Book : ICloneable<Book>
    {
        #region Properties

        public string Comments { get; set; }

        // TODO: implement entity ref
        public Location Location { get; set; }

        public string Name { get; set; }

        public Person Owner { get; set; }

        public Guid Id { get; set; }

        #endregion

        #region Implemented Interfaces

        #region ICloneable<Book>

        public Book Clone()
        {
            return new Book { Location = Location, Owner = Owner, Name = Name, Comments = Comments, Id = Id };
        }
        
        public void Update(Book book)
        {
            if (Id != book.Id)
            {
                throw new InvalidOperationException("Books with different id's could not be updated.");
            }

            Location = book.Location;
            Owner = book.Owner;
            Name = book.Name;
            Comments = book.Comments;
        }

        #endregion

        #endregion
    }
}